package com.design.movieticket.controller;

import com.design.movieticket.common.base.constant.Result;
import com.design.movieticket.common.base.constant.ResultStatus;
import com.design.movieticket.entity.MovieHall;
import com.design.movieticket.service.MovieHallService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@Api(tags = "影厅模块")
@RestController
@RequestMapping("/movieHall")
public class MovieHallController {
    @Resource
    private MovieHallService movieHallService;

    /** 获取影院影厅列表 */
    @ApiOperation("获取影院影厅列表")
    @GetMapping("/list/{id}")
    public Result getMovieHallByCinemaId(@PathVariable long id) {
        return new Result(movieHallService.getMovieHallListByCinemaId(id),ResultStatus.REQUEST_SUCCESS.getMsg(),ResultStatus.REQUEST_SUCCESS.getCode());
    }

    /** 新增或更新影厅数据 */
    @ApiOperation("新增或更新影厅数据")
    @PostMapping("/addOrUpdate")
    public Result addOrEditMovieHall(MovieHall movieHall) {
        movieHallService.addOrUpdateMovieHallInfo(movieHall);
        return new Result(ResultStatus.SAVE_SUCCESS.getMsg(),ResultStatus.SAVE_SUCCESS.getCode());
    }

    /** 获取影厅信息 */
    @ApiOperation("获取影厅信息详情")
    @GetMapping("/getMovieHallDetail/{id}")
    public Result getMovieHallDetail(@PathVariable long id){
        return new Result(movieHallService.getMovieHallDetail(id),ResultStatus.REQUEST_SUCCESS.getMsg(),ResultStatus.REQUEST_SUCCESS.getCode());
    }

    /** 删除影厅信息 */
    @ApiOperation("删除影厅信息")
    @PostMapping("/delMovieHallById/{id}")
    public Result delMovieHallById(@PathVariable long id){
        movieHallService.delMovieHallById(id);
        return new Result(ResultStatus.DELETE_SUCCESS.getMsg(),ResultStatus.DELETE_SUCCESS.getCode());
    }

    /** 更改影厅状态 */
    @ApiOperation("更改影厅状态")
    @PostMapping("/changeStatus/{id}")
    public Result changeMovieHallStatus(@PathVariable long id){
        movieHallService.changeMovieHallStatus(id);
        return new Result(ResultStatus.SAVE_SUCCESS.getMsg(),ResultStatus.SAVE_SUCCESS.getCode());
    }
}
